<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/reset.css">
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/home/info.css">
    <!-- 标题 -->
</script>
   
    <div class="layui-fluid">
        <div class="layui-row">
            <div class="InfoTitle layim-title">
                设备详细信息填写
            </div>
        </div>
    </div>
    <!-- 数据展示 -->
    <div class="layui-fluid">
        <form action="" method="" class="TaoYong" id="testDiv">
            <div>设备编号：</div>
        </form>
    </div>
    <!-- 确定和取消按钮 -->
    <div class="layui-fluid">
        <div class="layui-col-md12">
            <div class="InfoButton">
                <button id="btnSubmit" lay-submit lay-filter="btnSubmit">确定</button>
                <button>取消</button>
            </div>
        </div>
    </div>
    <script id="demo" type="text/html">
    <!-- layui-form -->
    <div class="FormData layui-row">
        <!-- 第一列 -->
        <div class="layui-form layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="llp layui-form-item layui-form">
                <label class="layui-form-label">设备ID:</label>
                <div class="layui-input-block">
                    {{ d.tcDevId }}
                </div>
              </div>

            <div class="llp layui-form-item layui-form">
                <label class="layui-form-label">设备编号:</label>
                <div class="layui-input-block">
                    {{ d.fia01 }}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">账套：</label>
                <div class="layui-input-block">
                    <select name="city" lay-verify="required" id="zhangTao">
                        <option value=""></option>
                        
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">资产编号:</label>
                <div class="layui-input-block">
                  <input type="text" name="fia011" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">设备编号:</label>
                <div class="layui-input-block">
                  <input type="text" name="fia01" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <!-- 需要带过来 -->
            <div class="llp layui-form-item layui-form">
                <label class="layui-form-label">设备类型：</label>
                <div class="layui-input-block">
                    {{d.fic02}}
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">启动日期:</label>
                <div class="layui-input-block">
                  <input type="text" name="fia19" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">保修日期:</label>
                <div class="layui-input-block">
                  <input type="text" name="fia20" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">*验收日期:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_dev_chkDate" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                *设备图片：
                <div type="text" id="id_upload" class="uploadeImag" placeholder="上传图片">
                   
                </div>
                <!-- 图片预览放大功能 -->
                <!--图片预览 -->
                <div class="photograph">
                    <ul id="path"></ul>
                </div>
            </div>
            
        </div>
        <!-- 第二列 -->
        <div class="layui-form layui-col-xs4 layui-col-sm4 layui-col-md4">
            <!-- 页面带过了 -->
            <div class="llp layui-form-item layui-form">
                <label class="layui-form-label">设备型号:</label>
                <div class="layui-input-block">
                    {{d.fii02}}
                </div>
            </div>

           
            <!-- 页面带过来 -->
            <div class="llp layui-form-item layui-form">
                <label class="layui-form-label">设备系列：</label>
                <div class="layui-input-block">
                    {{d.tcSeriesName}}
                </div>
            </div>
            
            
            <div class="layui-form-item">
                <label class="layui-form-label">设备状态：</label>
                <div class="layui-input-block">
                  <select name="city" lay-verify="required">
                    <option value=""></option>
                    
                  </select>
                </div>
            </div>
            
            <div class="llp layui-form-item layui-form">
                <label class="layui-form-label">供应商：</label>
                <div class="layui-input-block">
                    {{d.pmc081}}
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">负责部门：</label>
                <div class="layui-input-block">
                  <select name="city" lay-verify="required">
                    <option value=""></option>
                    
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">保管人：</label>
                <div class="layui-input-block">
                  <select name="city" lay-verify="required" lay-search id="selectPerone">
                    <option value=""></option>
                    
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">机合能力:</label>
                <div class="layui-input-block">
                  <input type="text" name="" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">精度:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_dev_precision" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            
            <!-- 回显设备类型 -->
            <div class="layui-form-item">
                <label class="layui-form-label">可生产产品类型:</label>
                <div class="layui-input-block">
                  <input type="text" name="" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">正常生产时长:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_prodTime" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">待机时长:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_maintTime" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">异常时长:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_excpTime" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">*安全说明:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_dev_chkDate" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

        </div>
        <!-- 第三个： -->
        <div class="ThreeDivBan layui-form layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item" style="width: 110px;">
                <label class="layui-form-label" style="width:85px;">设备调机人员：</label>
                <div class="layui-input-block">
                    <select name="city" lay-verify="required">
                        <option value=""></option>
                        
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">*厂房：</label>
                <div class="layui-input-block">
                    <select name="city" lay-verify="required">
                        <option value=""></option>
                        
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">*楼层：</label>
                <div class="layui-input-block">
                    <select name="city" lay-verify="required">
                        <option value=""></option>
                        
                    </select>
                </div>
            </div>

    
            <div class="layui-form-item">
                <label class="layui-form-label">*站别/工序：</label>
                <div class="layui-input-block">
                    <select name="fia16" lay-verify="required">
                        <option value=""></option>
                        
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">*线别：</label>
                <div class="layui-input-block">
                    <select name="fia17" lay-verify="required">
                        <option value=""></option>
                        
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">购买日期:</label>
                <div class="layui-input-block">
                <input type="text" name="fia18" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">维修保养时长:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_maintTime" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">产量:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_production" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否联机：</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_isOnine" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">驱动名称:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_drvName" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">设备IP:</label>
                <div class="layui-input-block">
                  <input type="text" name="tc_scada_ipAddress" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备注:</label>
                <div class="layui-input-block">
                  <input type="text" name="fia22" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    </script>
    <script>
        ! function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.$,
                admin = layui.admin,
                view = layui.view,
                api = layui.api,
                table = layui.table,
                setter = layui.setter,
                laytpl = layui.laytpl,
                utill = layui.utill,
                form = layui.form,
                element = layui.element;

            layui.use('form', function () {
                form = layui.form;
                form.on('submit(btnSubmit)', function (data) {
                })
            });
            $('[data-jump="home/cash"]').addClass('layui-this');
            var h = window.location.hash;
            var id = Number(h.substring(34));
            var oid = {
                id: id
            };
            var param = new Object();
            param.pageSize = 0;
            param.pageNum = 0;
            param.tcDevId = h.split("=")[1];
            $.ajax({
                url: api.host + "/fia/selectByFia01.json",
                data: JSON.stringify(param),
                async: false,
                type: 'post',
                dataType: 'json',
                contentType: "application/json",
                success: function (data) {
                    var data = data.data.list[0];

                    //请求成功时处理
                    laytpl($('#demo').html()).render(data, function (html) {
                        $('#testDiv').html(html);
                    });
                },

            })
            // 负责部门下拉框
            $.ajax({
                type: "post",
                url: api.host + "/ap/selectListName.json",
                success: function (data) {
                    var arr = [];
                    var arr1 = data.data;
                }
            })
            // 保管人下拉部门
            $.ajax({
                type: 'post',
                url: api.host + '/fia/selectFia10.json',
                success: function (response) {
                    var response = response.data;
                    var select = document.getElementById('selectPerone');
                    if (response != null || response.size() > 0) {
                        for (var re in response) {
                            var option = document.createElement("option");
                            option.setAttribute("value", response[re].gen01);
                            option.innerText = response[re].gen02;
                            select.appendChild(option)
                        }
                        form.render('select');
                    };
                }
            })
            // 设备调机人员
            $.ajax({
                type: "post",
                url: api.host + "/fia/selectFiaUser.json",
                success: function (res) {
                    var list = res.data;
                    var select = document.getElementById('equimenSelectTwo');
                    if (list != null || list.size() > 0) {
                        for (var res in list) {
                            var option = document.createElement("option");
                            option.setAttribute("value", list[res].gen01);
                            option.innerText = list[res].gen02;
                            select.appendChild(option)
                        }
                        form.render('select');
                    };
                }
            })

            // 账套：
            $.ajax({
                type: 'post',
                // url: 'http://192.168.0.109:8081/fil/AzpSelectAllAzp.json',
                // data:{
                //    azpo2:""
                // },
                success: function (res) {
                    var res = res.data;
                    var select = document.getElementById('zhangTao');
                    if (res != null || res.size() > 0) {
                        for (var rout in res) {
                            var option = document.createElement("option");
                            option.setAttribute("value", res[rout].gen01);
                            option.innerText = res[rout].gen02;
                            select.appendChild(option)
                        }
                        form.render('select');
                    };
                }
            })
            
            //文件上传功能
            layui.use('upload', function () {
                var upload = layui.upload;
                var $ = layui.jquery
                //执行实例
                var uploadInst = upload.render({
                    elem: '#id_upload',
                    url: 'http://192.168.0.110:8081/fia/upload.json',
                    multiple: true,
                    size: 1000, //限制文件大小，单位 KB
                    method: 'POST'
                    , accept: 'images',
                    before: function (data) {
                    }
                    , done: function (res) {
                        //$("#pic").val(res.url);
                        // alert(res.url);
                        var i = 1;
                        $("#path").append("<li Style='color: red;float:left;'><img src=http://192.168.0.109:8081/" + res.data[0] + " style='width: 40px; height: 40px;'/><input class='path' value=" + res.data[0] + " style='display:none' /></li>")
                        i++;
                    }
                    , error: function () {
                        alert("系统异常");
                    }

                });
                $("#btnSubmit").click(function () {

                    //获得一组值
                    var paths = new Array();
                    $(".path").each(function (key, value) {
                        paths[key] = $(this).val();
                        //  或者 btns[key] = $(value).val();
                    })
                    var param=$.serializeJSON($("#testDiv"));//表单的值
                        param.tcFilePath=paths ;
                    $.ajax({
                    url: "http://192.168.0.110:8081/fia/insertFiaFile.json",
                    data: JSON.stringify(param),
                    async: false,
                    type: 'post',
                    dataType: 'json',
                    contentType: "application/json",
                    success: function (data) {
                },

            })
                })
                $("#path").on("click", "li", function () {
                    $(this).remove();
                });
                ; $.extend({
                    serializeJSON: function (obj) {
                        var formArr = obj.serializeArray();
                        var formObj = new Object();
                        $.each(formArr, function () {
                            if (formObj[this.name]) {
                                if (!formObj[this.name].push) {
                                    formObj[this.name] = [formObj[this.name]];
                                }
                                formObj[this.name].push(this.value || '');
                            } else {
                                formObj[this.name] = this.value || '';
                            }
                        });
                        return formObj;
                    }
                });
            })
        }();
    </script>
</body>

</html>